x <- matrix( rnorm(100 * 1000), ncol = 1000 )
system.time( apply(x, 2, median) )
system.time( colMedians(x) )
system.time( colMedians_parallel(x, ncores = 2) )
a <- apply(x, 2, median)
b1 <- colMedians(x)
b2 <- colMedians_parallel(x, ncores = 2)
all.equal(a, b1)
all.equal(a, b2)
Run the code above in your browser using DataLab